package com.api.server.service.impl;

import com.api.server.mapper.UserMapper;
import com.api.server.pojo.Controller;
import com.api.server.mapper.ControllerMapper;
import com.api.server.service.IControllerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author shi
 * @since 2022-04-28
 */
@Service
public class ControllerServiceImpl extends ServiceImpl<ControllerMapper, Controller> implements IControllerService {

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private UserMapper userMapper;

    @Override
    public void registercontroller(Controller controller) {
        controller.setUserpassword(passwordEncoder.encode(controller.getUserpassword()));
        controller.setUsergrade("1");
        controller.setState("1");
        userMapper.insert(controller);
    }
}
